import { plugin, Messagetype, segment } from 'alemon'
import axios from 'axios'
export class PluginName extends plugin {
  constructor() {
    super({
      dsc: '每天60秒读懂世界',
      rule: [
        {
          reg: '^/60s',
          fnc: 'lsS'
        }
      ]
    })
  }
  async lsS(e: Messagetype) {
    if (e.eventType !== 'CREATE' && e.event !== 'MESSAGES') {
      return
    }
    const res = await axios.get('https://api.vvhan.com/api/60s?type=json').catch(err => err)
    if (!res || !res.data || !res.data.success) {
      return e.reply('60s 查询失败')
    }

    return e.reply(segment.image(res.data.imgUrl))
  }
}
